#!/bin/bash

if [ -n "$1" ] ; then
  data_date=$1
else
  data_date=`date -d '-1 days' +%F`
fi


ODS_ADS_LOG_INC_MYSQL="
LOAD DATA INPATH 'hdfs://node101:8020/warehouse/app_logs/${data_date}'
    INTO TABLE jtp_warehouse.ods_ads_log_inc PARTITION (dt = '${data_date}');
"

ODS_ADS_LOG_FULL_MYSQL="
LOAD DATA INPATH 'hdfs://node101:8020/warehouse/app_ads/ads/${data_date}'
    OVERWRITE INTO TABLE jtp_warehouse.ods_ads_log_full PARTITION (dt = '${data_date}');
"

ODS_ADS_PLATFORM_FULL_MYSQL="
LOAD DATA INPATH 'hdfs://node101:8020/warehouse/app_ads/ads_platform/${data_date}'
    OVERWRITE INTO TABLE jtp_warehouse.ods_ads_platform_full PARTITION (dt = '${data_date}');
"

ODS_PLATFORM_INFO_FULL_MYSQL="
LOAD DATA INPATH '/warehouse/app_ads/platform_info/${data_date}' OVERWRITE INTO TABLE
    jtp_warehouse.ods_platform_info_full PARTITION (dt = '${data_date}');
"

ODS_PRODUCT_FULL_MYSQL="
LOAD DATA INPATH '/warehouse/app_ads/product/${data_date}' OVERWRITE INTO TABLE
    jtp_warehouse.ods_product_full PARTITION (dt = '${data_date}');
"


/opt/module/spark/bin/beeline -u jdbc:hive2://node101:10001 -n bwie -e  \
"${ODS_ADS_LOG_INC_MYSQL}${ODS_ADS_LOG_FULL_MYSQL}${ODS_ADS_PLATFORM_FULL_MYSQL}${ODS_PLATFORM_INFO_FULL_MYSQL}${ODS_PRODUCT_FULL_MYSQL}"